//
// Created by thinkpad on 16-12-24.
//题目：字符串反转，thinkpad转换为dapkniht
#include <stdio.h>
void reverse(char* s){
    //获取字符串长度
    int len = 0;
    //指针，C 语言中string就是char字符数组，所以指针char可用
    char* p = s;
    while (*p !=0){
        len++;
        p++;
    }
    //交换
    int i = 0;
    char c;
    while(i<=len/2-1){
        c = *(s+1);
        *(s+i) = *(s+len-1-i);
        *(s+len-1-i) = c;
        i++;
    }
}

int main(){
    char s[] = "thinkpad";
    printf(" '%s' => \n",s);
    reverse(s);
    printf("'%s' \n",s);
    return 0;
}